package com.edu.web.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.edu.entity.Reason;
import com.edu.entity.ReasonTa;
import com.edu.entity.User;
import com.edu.service.impl.GreenUserSericeImpl;
import com.edu.service.impl.ReasonServiceImpl;
import com.edu.service.impl.UserServiceImpl;

/**
 * Servlet implementation class InserYuanServlet
 */
@WebServlet("/InserYuanServlet")
public class InserYuanServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
   
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		UserServiceImpl userServletImpl=new UserServiceImpl();
		GreenUserSericeImpl greenUserSericeImpl =new GreenUserSericeImpl();
		Reason user=new Reason();
		ReasonTa u =new ReasonTa();
		user.setAuthor(request.getParameter("passwords"));
		user.setCollect(Integer.parseInt(request.getParameter("cous")));
		user.setTargets(Integer.parseInt(request.getParameter("sexss")));
		user.setTheme(request.getParameter("nameusers"));
		user.setTitle(request.getParameter("ocps"));
		u.setDonationsContent(request.getParameter("eamis"));
		u.setDonationsContents(request.getParameter("yuan"));
		userServletImpl.InsertRe(user);
		userServletImpl.InsertRes(u);
		ReasonServiceImpl Reason =new ReasonServiceImpl();
		request.setAttribute("Reason", Reason.allC());
		request.getRequestDispatcher("manage-Yuan.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
